<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>咨询记录列表</title>
    <?php require 'templates/common/head.html'; ?>
</head>
<body>
    <div class="container-fluid">
    <?php require 'templates/common/nav.html'; ?>
        <div class="panel panel-primary">
            <div class="panel-heading text-center">
                <h3 class="panel-title">咨询记录列表</h3>
            </div>
            <div class="panel-body" style="text-align:center">
                <div class="panel-heading text-right">
                <a href="index.php?m=push_information&a=add_information" type="button" class="btn btn-primary">添加模板资讯</a>
                </div>
                <div class="panel-heading text-right">
                       测试openID: <input type="text" id="oid">
                </div>
                <div class="panel-group"  id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" style="background-color:#d5d5d5">
                            <div class="row" >
                                <div class="col-xs-1 col-sm-1">排序</div>
                                <div class="col-xs-3 col-sm-3">标题</div>
                                <div class="col-xs-1 col-sm-1">发布人</div>
                                <div class="col-xs-2 col-sm-2">发布时间</div>
                                <div class="col-xs-1 col-sm-1">是否发送</div>
                                <div class="col-xs-1 col-sm-1">添加时间</div>
                                <div class="col-xs-3 col-sm-3" style="text-align:center">操作</div>
                            </div>
                        </div>
                    </div>
                    <?php foreach($informations as $k=>$v):?>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="row" >
                                    <div class="col-xs-1 col-sm-1"><?=$k+1;?>&nbsp;</div>
                                    <div class="col-xs-3 col-sm-3"><?=$v['标题']?>&nbsp;</div>
                                    <div class="col-xs-1 col-sm-1"><?=$v['发布人']?>&nbsp;
                                    </div>
                                    <div class="col-xs-2 col-sm-2"><?=$v['发布时间']?>&nbsp;</div>
                                    <div class="col-xs-1 col-sm-1"><?=$v['发送']?>&nbsp;</div>
                                    <div class="col-xs-1 col-sm-1"><?=$v['添加时间']?></div>
                                    <div class="col-xs-3 col-sm-3" style="text-align:center">
                                        <!--<button onclick="ceshi('<?=$v['id']?>')" class="btn btn-primary btn-xs">测试</button>-->
                                        <a href="index.php?m=push_information&a=add_information&id=<?=$v['id']?>&page=<?=$_GET['page']?>"class="btn btn-primary btn-xs">编辑</a>
                                        <a href="index.php?m=push_information&a=information_detail&id=<?=$v['id']?>" class="btn btn-primary btn-xs">查看图文</a>

                                        <button onclick="disabled=true;tuisong('<?=$v['id']?>')" class="btn btn-primary btn-xs">推送</button>
                                    </div>

                                </div>
                            </div>
                        </div>
                    <?php  endforeach;?>
                </div>
                <div><?=$page->showpage()?></div>
            </div>
        </div>
    </div>
<?php require 'templates/common/foot.html'; ?>
<script language="JavaScript">
    function ceshi(id){
        var oid=$("#oid").val();
        if(oid){
            $.post('index.php?m=push_information&a=push_message',{'id':id,'oid':oid},function(data){
                var res= eval('(' + data + ')');
                if(res.result==0){
                    alert("测试通过");
                }else{
                    alert(res.message);
                }
                location.reload();
            });
        }else{
            alert('请填写oid');
        }

    }

    function tuisong(id){
        var oid=$("#oid").val();
        if(oid){
            var res = confirm("您确定给’"+oid+"’推送消息吗?");
        }else{
            var res = confirm("您确定给全部用户推送消息吗？");
        }
        if(res)
        {
            $.post('index.php?m=push_information&a=push_message',{'id':id,'oid':oid},function(data){
                var res= eval('(' + data + ')');
                if(res.result==0){
                    //成功
                    alert(res.message);
                }else{
                    alert(res.message);
                }
                location.reload();
            });
            alert("触发成功");
        }

    }
</script>
</body>
</html>